// pages/template/dialphone.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dialphone: {
      type: Object,
      value: {
        isShow: false,
        animate: false,
        numString: 18000000000
      }
    },
    animationData: {
      type: Function,
      value: function () { }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 阻止冒泡事件
     */
    catchtap: function () { },
    /**
     * 取消弹框
     */
    hidemask: function () {
      var that = this,
        dialphone = that.data.dialphone,
        time = 200;
      dialphone.isShow = true;
      dialphone.animate = false;
      that.setData({
        dialphone: dialphone
      });
      setTimeout(function () {
        dialphone.isShow = false;
        that.setData({
          dialphone: dialphone
        });
      }, time);
    },
    /**
     * 拨打电话
     */
    phonecall: function () {
      var that = this,
        dialphone = that.data.dialphone;
      wx.makePhoneCall({
        phoneNumber: dialphone.numString,
        success: function () {

        },
        fail: function () {

        }
      })
    },
    /**
     * 复制文本
     */
    copytext: function () {
      var that = this,
        dialphone = that.data.dialphone;
      wx.setClipboardData({
        data: dialphone.numString,
        success: function (res) {
          wx.showToast({
            title: '复制成功',
            icon: 'none'
          })
        },
        fail: function (res) {
          wx.showToast({
            title: '复制失败',
            icon: 'none'
          })
        }
      })
    }
  }
})
